<template>
  <!-- 委外案件查询 -->
  <section class="page query-case-out-record">
    <data-form :model="searchModel" :page="pageService" @handleResetForm="handleResetForm" @onSearch="refreshData">
      <template slot="inputs">
        <el-form-item label="订单编号" prop="caseNumber">
          <el-input v-model="searchModel.caseNumber"></el-input>
        </el-form-item>
        <el-form-item label="批次号" prop="outBatch">
          <el-input v-model="searchModel.outBatch"></el-input>
        </el-form-item>
        <el-form-item label="客户姓名" prop="personalName">
          <el-input v-model="searchModel.personalName"></el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="idCard">
          <el-input v-model="searchModel.idCard"></el-input>
        </el-form-item>
        <el-form-item label="委外方" prop="outsourceId">
          <el-select clearable placeholder="请选择" v-model="searchModel.outsourceId">
            <el-option :key="item.id" :label="item.outsName" :value="item.id" v-for="item in outSourceList"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="委外时间" prop="caseTurnTime">
          <el-date-picker :editable="false" clearable placeholder="选择日期时间" type="daterange" v-model="searchModel.outTime"></el-date-picker>
        </el-form-item>
        <el-form-item label="委外结束时间" prop="caseTurnTime">
          <el-date-picker :editable="false" clearable placeholder="选择日期时间" type="daterange" v-model="searchModel.outEndDate"></el-date-picker>
        </el-form-item>
        <el-form-item label="案件金额" prop="caseMoney">
          <number-range :isInteger="true" v-model="searchModel.caseMoney"></number-range>
        </el-form-item>
      </template>
    </data-form>

    <data-box :data="dataSet" :page="pageService" @onPageChange="refreshData">
      <template slot="columns">
        <!--数据列区域-->
        <el-table-column :min-width="$helper.getColumnWidth(5)" label="批次号" prop="outBatch" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(7)" label="订单编号" prop="caseNumber" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(7)" label="客户姓名" prop="personalName" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(7)" label="身份证号码" prop="idCard" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="案件金额" prop="caseMoney"></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="欠款金额(元)" prop="overdueAmount" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="委外方" prop="outsourceName" show-overflow-tooltip></el-table-column>
        <el-table-column :formatter="(row) => $filter.dateFormat(row.outerBeginDate)" :min-width="$helper.getColumnWidth(7)" label="委外开始时间" prop="outerBeginDate" show-overflow-tooltip></el-table-column>
        <el-table-column :formatter="(row) => $filter.dateFormat(row.outerEndDate)" :min-width="$helper.getColumnWidth(7)" label="委外结束时间" prop="outerEndDate" show-overflow-tooltip></el-table-column>
      </template>
    </data-box>
  </section>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Auth, Layout, Dependencies } from "~/core/decorator";
import { PageService } from "~/utils/page.service";
import DataForm from "~/components/common/data-form.vue";
import DataBox from "~/components/common/data-box.vue";
import { SortService } from "~/utils/sort.service";
import NumberRange from "~/components/common/number-range.vue";
import { SynthesizeQueryService } from "~/services/domain-service/synthesize-query.service";
import { Mutation, Getter, namespace, State } from "vuex-class";
const CollectionExecutionModule = namespace("collection-execution");
@Layout("workspace")
@Component({
  components: {
    NumberRange
  }
})
export default class QueryCaseOutRecord extends Vue {
  @Dependencies(PageService) private pageService: PageService;
  @Dependencies(SortService) private sortService: SortService;
  @Dependencies(SynthesizeQueryService)
  private synthesizeQueryService: SynthesizeQueryService;

  @CollectionExecutionModule.Action private openCollectionExecution;
  @State private outSourceList;

  private searchModel: any = {
    caseNumber: "",
    outBatch: "",
    outsourceId: "",
    personalName: "",
    idCard: "",
    outEndDate: [],
    outTime: [],
    caseMoney: { min: "", max: "" }
  };

  private dataSet: any[] = [];

  private refreshData() {
    this.synthesizeQueryService
      .queryCaseOutRecords(this.searchModel, this.pageService)
      .subscribe(data => (this.dataSet = data));
  }

  private mounted() {
    this.refreshData();
  }

  private handleResetForm() {
    this.searchModel.outEndDate = { max: "", min: "" };
    this.searchModel.outTime = { max: "", min: "" };
    this.searchModel.caseMoney = { min: "", max: "" };
  }
}
</script>
<style lang="less">
</style>
